A 0
B 0
C 0
D 810
E 0
F 0
G 0
H 294
I 573
J 244
K 0
L 0
M 0
N 0
O 481
P 0
Q 0
R 0
S 0
T 0
U 0
V 0
W 0
X 0
Y 0
Z 0
dtype: int32
Kerry Back
Here are the trades:
A 0
B 0
C 0
D 810
E 0
F 0
G 0
H 294
I 573
J 244
K 0
L 0
M 0
N 0
O 481
P 0
Q 0
R 0
S 0
T 0
U 0
V 0
W 0
X 0
Y 0
Z 0
dtype: int32
sellall = (ranks>10) & (positions !=0)
sellallamounts = positions
trades = - np.where(sellall, sellallamounts, 0)
sellsome = (ranks<=10) & (weights>0.2)
sellsomeamounts = (equity*(weights-0.2)/prices).astype(int)
trades -= np.where(sellsome, sellsomeamounts, 0)
trades = pd.Series(trades, index=ranks.index)
cash -= (trades*prices).sum()Here are the trades:
A 0
B 401
C 0
D -40
E 0
F 0
G 0
H 0
I 0
J -6
K 0
L 0
M 0
N 21
O -481
P 0
Q 0
R 0
S 0
T 0
U 0
V 0
W 0
X 0
Y 0
Z 0
dtype: int32